//
//  ContectCell.m
//  UI_Homewor_13
//
//  Created by 黄威 on 16/5/19.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "ContectCell.h"
@interface ContectCell ()
@property (nonatomic,retain)UILabel *summary;
@end
@implementation ContectCell


+(CGFloat)HeigtForContect:(NSString *)text{


    return [text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont
        systemFontOfSize:17]} context:nil].size.height;


}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)setModel:(Model *)model{

    if (_model != model) {
        [_model release];
        _model = [model retain];
    }

    self.summary.text = model.summary;
    
    
}

-(void)layoutSubviews{


    self.summary.frame = CGRectMake(0, 0, self.frame.size.width, [ContectCell HeigtForContect:self.summary.text]);

    NSLog(@"%f", self.contentView.frame.size.height);
    NSLog(@"%f", self.summary.frame.size.height);

}

- (void)createSubviews{

    self.summary = [[UILabel alloc]init];
    
    [self.contentView addSubview:self.summary];

    self.summary.numberOfLines = 0;

}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
